package cn.wolfcode.web.controller;
import cn.wolfcode.enums.ConsumptionReportEnums;
import cn.wolfcode.qo.ConsumptionReportQueryObject;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.IConsumptionReportService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/consumptionReport")
public class ConsumptionReportController {
    @Autowired
    private IConsumptionReportService consumptionReportService;
    @Autowired
    private IBusinessService businessService;
    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") ConsumptionReportQueryObject qo, Model model){
       model.addAttribute("pageInfo",consumptionReportService.query(qo));
       model.addAttribute("business",businessService.listAll());
       model.addAttribute("groupByItems", ConsumptionReportEnums.values());
        return "/businessReport/list";
    }
    @RequestMapping("/echart")
    public String echart(@ModelAttribute("qo") ConsumptionReportQueryObject qo, Model model){
        qo.setPageSize(0);
        PageInfo pageInfo = consumptionReportService.query(qo);
        model.addAttribute("items",pageInfo.getList());
        return "/businessReport/echart";
    }
}
